import { CVERSION, CHANNEL } from '../globalData'
import { str2EncodeByDES } from '../tripledes'

const requestDefaultData = {
    cversion: CVERSION,
    channel: CHANNEL,
    pdata: null,
    sdt: null
};

const setRequestData = (params, isEncode) => {
    if (params && isEncode) {
        params = {
            pdata: null,
            sdt: str2EncodeByDES(params)
        }
    }
    return {
        ...requestDefaultData,
        ...params
    }
};

const setRequestHeader = (params) => {
    return {
        sessionId: wx.getStorageSync("sessionId") || null,
        ...params
    }
};

module.exports = {
    setRequestData,
    setRequestHeader
};